package com.imooc.sell.dataobject;

import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Proxy;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 月统计实体类
 */
@Entity
@Data
@Proxy(lazy = false)
@DynamicUpdate
public class SellByMonth extends AbstractStat {
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer statByMonthId;
    /**
     * 月销量
     */
    private Integer sellSuccessMonth;
    /**
     * 月销售额
     */
    private BigDecimal successMonthSale;
    /**
     * 月取消订单数
     */
    private Integer sellCancelMonth;
    /**
     * 月退款订单数
     */
    private Integer sellPaybackMonth;
    /* 更新时间*/
    private Date updateTime;

    public SellByMonth() {

    }

    public SellByMonth(Integer sellSuccessMonth, BigDecimal successMonthSale, Integer sellCancelMonth, Integer sellPaybackMonth) {
        this.sellSuccessMonth = (Integer) check(sellSuccessMonth, Integer.class);
        this.successMonthSale = (BigDecimal) check(successMonthSale, BigDecimal.class);
        this.sellCancelMonth = (Integer) check(sellCancelMonth, Integer.class);
        this.sellPaybackMonth = (Integer) check(sellPaybackMonth, Integer.class);
    }

    public void upToDad() {
        setSellSuccess(getSellSuccessMonth());
        setSuccessSale(getSuccessMonthSale());
        setSellCancel(getSellCancelMonth());
        setSellPayback(getSellPaybackMonth());
        setDate(getUpdateTime());
    }
}
